import Utilitys.DruidMySql;
import Utilitys.Log;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/log")
public class ServiceLog extends GenericServlet {

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("<=======Log表单=====>");
        QueryRunner queryRunner = DruidMySql.getQueryRunner();
        String sql = "select * from operation_log";
        List<Log> query = null;
        try {
            query = queryRunner.query(sql, new BeanListHandler<>(Log.class));
            query.forEach(System.out::println);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
